package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.IotEnterpriseManage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-20 11:33:47
 */
@Repository
public class IotEnterpriseManageDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(IotEnterpriseManageDao.class);

    public IotEnterpriseManage insert(final IotEnterpriseManage iotEnterpriseManage) {
        insert("IotEnterpriseManage.insert", iotEnterpriseManage);
        return iotEnterpriseManage;
    }

    public Boolean updateInfoById(final IotEnterpriseManage iotEnterpriseManage) {
        return update("IotEnterpriseManage.updateInfoById", iotEnterpriseManage) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("IotEnterpriseManage.updateInfoByQuery", query) > 0;
    }

    public IotEnterpriseManage selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("IotEnterpriseManage.selectById", query);
    }

    public List<IotEnterpriseManage> selectByQuery(final Query query) {
        return queryForList("IotEnterpriseManage.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("IotEnterpriseManage.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        IotEnterpriseManage iotEnterpriseManage = new IotEnterpriseManage();
        iotEnterpriseManage.setDeleteFlag(1);
        iotEnterpriseManage.setId(id);

        return update("IotEnterpriseManage.updateInfoById", iotEnterpriseManage) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("IotEnterpriseManage.deleteById", query) > 0;
    }
}